package com.seed.application.selector;

import com.seed.application.Sa;
import com.seed.application.selector.impl.AppSeedSelector;
import com.seed.application.selector.impl.DevSeedSelector;
import com.seed.application.selector.impl.MicroSeedSelector;
import com.seed.application.selector.impl.SingleSeedSelector;
import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;

import java.util.function.Predicate;

public class SeedSelector implements ImportSelector {

    private ImportSelector importSelector;

    public SeedSelector() {
        this.importSelector = switch (Sa.getMode()) {
            case dev -> new DevSeedSelector();
            case single -> new SingleSeedSelector();
            case app -> new AppSeedSelector();
            case micro -> new MicroSeedSelector();
        };
    }

    @Override
    public String[] selectImports(AnnotationMetadata importingClassMetadata) {
        return this.importSelector.selectImports(importingClassMetadata);
    }

    public Predicate<String> getExclusionFilter() {
        return importSelector.getExclusionFilter();
    }
}
